﻿using Authentication.Core.Data;
using Authentication.Model.Interface;
using Authentication.Model.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Authentication.Provider
{
    public class CustomerProvider : GenericProvider, ICustomerProvider
    {
        public List<Customers> RetrieveListCustomerByCif(List<string> listCif)
        {
            var data = repository.DbContext as AuthenticationEntities;
            var query = from x in data.Customers
                        where listCif.Contains(x.Cif)
                        select x;
            return query.ToList();
        }
        public List<Customers> RetrieveListCustomerByCifAndBranch(List<string> listCif, string branchId)
        {
            var data = repository.DbContext as AuthenticationEntities;
            var query = from x in data.Customers
                        where listCif.Contains(x.Cif) && branchId.Equals(x.BranchId)
                        select x;
            return query.ToList();
        }
        public List<Customers> RetrieveListCustomerByDao(List<string> listDao, string branchId = null)
        {
            var data = repository.DbContext as AuthenticationEntities;
            var query = from x in data.Customers
                        where listDao.Contains(x.Dao)
                        select x;
            if (!string.IsNullOrEmpty(branchId))
            {
                query = query.Where(x => x.BranchId.Equals(branchId));
            }
            return query.ToList();
        }
        
    }

}
